/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/
#pragma once

#include <baja/common.hpp>
#include <baja/error.hpp>
#include <baja/assert.hpp>

namespace baja {

enum class var_flags : uint32
{
    readOnly = 0x1
};

enum class var_type : uint32
{ 
    typeBool = 0, 
    typeInt = 1, 
    typeUint = 2,
    typeFloat = 3,
    typeString = 4,
    typeEnum = 5
}; 

struct ivar_wrapper : public ibase
{
    BAJA_INTERFACE(ivar_wrapper, "EC958B91-17D4-49a9-8E67-DDDC9B21F1F9")

    virtual void increment() = 0;
    virtual void incrementAndWrap() = 0;
    virtual void decrement() = 0;

    virtual std::wstring getName() = 0;
    virtual var_type getType() = 0;
    virtual uint32 getFlags() = 0;
    virtual void* getData() = 0;
    virtual std::wstring getDataAsString() = 0;
};

struct ivar_group: public ibase
{
    BAJA_INTERFACE(ivar_group, "9F8F0926-6B1B-48e3-BEA1-7052EAD5E8DC")

    virtual std::wstring getName() = 0;

    virtual std::shared_ptr<ivar_group> getParent() = 0;

    virtual void addChildGroup(const std::shared_ptr<ivar_group>& group) = 0;
    virtual void removeChildGroup(const std::shared_ptr<ivar_group>& group) = 0;

    virtual size_t getChildGroupCount() = 0;
    virtual std::shared_ptr<ivar_group> getChildGroup(const uint32 index) = 0;

    virtual void addBoolVar(const wchar* name, bool* data, const uint32 flags) = 0;
    virtual void addIntVar(
        const wchar* name,
        int* data,
        const int minValue,
        const int maxValue,
        const int changeStep,
        const uint32 flags
        ) = 0;

    virtual void addUintVar(
        const wchar* name,
        uint32* data,
        const uint32 minValue,
        const uint32 maxValue,
        const uint32 changeStep,
        const uint32 flags
        ) = 0;

    virtual void addFloatVar(
        const wchar* name,
        float* data,
        const float minValue,
        const float maxValue,
        const float changeStep,
        const uint32 flags
        ) = 0;

    virtual void addStringVar(
        const wchar* name,
        wchar* data,
        const uint32 flags
        ) = 0;

    virtual void addEnumVar(
        const wchar* name,
        int* data,
        const int* enumValues,
        const wchar** enumNames,
        const uint32 totalValues,
        const uint32 flags
        ) = 0;

    virtual size_t getVarCount() = 0;
    virtual std::shared_ptr<ivar_wrapper> getVar(const size_t index) = 0;
};

std::shared_ptr<ivar_group> createVarGroup(const wchar* name);

} // namespace baja

#include <baja/vars_impl.hpp>